#include <stdio.h>


int str=0;

void put(char board[][8],int x,int y) {
    int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
    int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
    if (board[x][y] == '.') {
        board[x][y] = 'Q';
    }
    for (int i = 1; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            int nx = x + i * dx[j];
            int ny = y + i * dy[j];
            if (nx < 8 && nx >= 0 && ny < 8 && ny >= 0) {
                if (board[nx][ny] == '.') {
                    board[nx][ny] = '1';
                }

            }
        }
    }

}


void mytry(char board[][8],char queen[][8],int y) {
    if (y == 8) {
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if (queen[i][j] == 'Q') {
                    str = (j + 1) + str * 10;
                    break;
                }
            }
        }
        return;
    }
    for (int i = 0; i < 8; i++) {
        if (str != 0)
            return;
        if (board[y][i] == '.') {
            char temp[8][8];
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    temp[i][j] = board[i][j];
                }
            }
            queen[y][i] = 'Q';
            put(board, y, i);
            mytry(board, queen, y + 1);
            queen[y][i] = '\0';
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    board[i][j] = temp[i][j];
                }
            }
        }

    }
}



int main()
{
    char board[8][8];
    char queen[8][8];
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            scanf("%c",&board[i][j]);
        }
        scanf("%*c");
    }
    mytry(board,queen,0);
    printf("%d",str);
    return 0;
}
